package hacker_rank.feb14;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class BikeRacers {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[]line = br.readLine().split(" ");
		int N = Integer.parseInt(line[0]);
		int M = Integer.parseInt(line[1]);
		int k = Integer.parseInt(line[2]);
		
		Point[] bikers = new Point[N];
		for(int n = 0; n < N; n++) {
			line = br.readLine().split(" ");
			bikers[n] = new Point(Integer.parseInt(line[0]), Integer.parseInt(line[1]));
		}
		
		//System.out.println(Arrays.toString(bikers));
		Point[]bikes = new Point[M];
		
		for(int m = 0; m < M; m++) {
			line = br.readLine().split(" ");
			bikes[m] = new Point(Integer.parseInt(line[0]), Integer.parseInt(line[1]));
		}
		//System.out.println(Arrays.toString(bikes));
		
		Point x1[] = new Point[bikes.length];
		Point y1[] = new Point[bikes.length];
		for(int i = 0; i < bikes.length; i++) {
			x1[i] = new Point(bikes[i].x, bikes[i].y);
			y1[i] = new Point(bikes[i].x, bikes[i].y);
		}

		Point x2[] = new Point[bikers.length];
		Point y2[] = new Point[bikers.length];
		for(int i = 0; i < bikers.length; i++) {
			x2[i] = new Point(bikers[i].x, bikers[i].y);
			y2[i] = new Point(bikers[i].x, bikers[i].y);
		}
		
		Arrays.sort(x1, new XComp());
		Arrays.sort(x2, new XComp());
		
		Arrays.sort(y1, new YComp());
		Arrays.sort(y2, new YComp());
		k--;
		
		long res[] = new long[6];
		
		res[0] = dist(x1, x2, k);
		res[1] = dist(x1, y1, k);
		res[2] = dist(x1, y2, k);
		res[3] = dist(x2, y1, k);
		res[4] = dist(x2, y2, k);
		res[5] = dist(y1, y2, k);
		
	//	System.out.println(Arrays.toString(res));
		
		long r = Long.MAX_VALUE;
		
		for(long l : res) {
			if(l < r && l > 0)
				r = l;
		}
		System.out.println(r);
	}
	static long dist(Point[] p1, Point[] p2, int k)
	{
		long xd = p1[k].x - p2[k].x;
		long yd = p1[k].y - p2[k].y;
		return (xd * xd) + (yd * yd);
	}
	
	static class XComp implements Comparator<Point> {

		@Override
		public int compare(Point o1, Point o2) {
			Point p1 = (Point) o1;
			Point p2 = (Point) o2;
			return p1.x - p2.x;
		}
		
	}
	
	static class YComp implements Comparator<Point> {
		@Override
		public int compare(Point o1, Point o2) {
			Point p1 = (Point) o1;
			Point p2 = (Point) o2;
			return p1.y - p2.y;
		}
		
	}
	
	static class Point {
		public int x;
		public int y;
		
		Point(int x, int y)
		{
			this.x = x;
			this.y = y;
		}

		public long distance2(Point p) {
			long xd = this.x - p.x;
			long yd = this.y - p.y;
			return (xd * xd) + (yd * yd);
		}
		
		@Override
		public String toString()
		{
			return String.format("(%d, %d)", x, y);
		}
		
	}

}
